<%@ page import="com.bdqn.t382.pojo.SysUser" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2025-02-26
  Time: 18:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户列表</title>
</head>
<style>
    form {
        text-align: center;
    }
</style>
<body>
<%
    SysUser user = (SysUser) session.getAttribute("user");
    if (user == null) {
        response.sendRedirect("/springmvc_war_exploded/error.jsp");
    }
%>
<h2 align="center">${user.realName}欢迎您!</h2>
<%--<form action="${pageContext.request.contextPath}/user/list" method="get">--%>
<%--    账号:<input type="text" name="account" value="${param.account}"/> <input type="submit" value="查询">--%>
<%--</form>--%>
<table border="1" align="center">
    <tr>
        <td colspan="5"><a href="${pageContext.request.contextPath}/user/addUser">增加</a></td>
    </tr>
    <tr>
        <td>账号</td>
        <td>真实姓名</td>
        <td>手机号码</td>
        <td>地址</td>
        <td>操作</td>
    </tr>
    <tr>
        <c:forEach items="${list}" var="sysUser">
        <td>${sysUser.account}</td>
        <td>${sysUser.realName}</td>
        <td>${sysUser.phone}</td>
        <td>${sysUser.address}</td>
        <td>
            <a href="view?id=${sysUser.id}">查看详细</a>
            <a href="toUpdate?id=${sysUser.id}">编辑</a>
            <a href="javaScript:void(0)" onclick="del(${sysUser.id})">删除</a></td>
    </tr>
    </c:forEach>
</table>
<p align="center">
    <a href="${pageContext.request.contextPath}/user/list?pageNo=1">首页</a>
    <a href="${pageContext.request.contextPath}/user/list?pageNo=${pageNo-1}">上一页</a>
    <a href="${pageContext.request.contextPath}/user/list?pageNo=${pageNo+1}">下一页</a>
    <a href="${pageContext.request.contextPath}/user/list?pageNo=${totalPage}">末页</a>
    共有${totalCount}条记录
</p>
</body>
<script>
    function del(id) {
        let con = confirm("确认要删除第" + id + "行数据吗");
        if (con) {
            location = 'delete?id=' + id;
        }
    }
</script>
</html>
